package com.test;

import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Demo1 {

    @Test
    public void t1() {

        String a = null;
        String b = "";
        // boolean equals = a.equals(b);
        // System.out.println(equals);
        // if ("1".equals("参数") && Objects.equals("1", b)) {
        if (Objects.equals(a, b)) {
            System.out.println("执行新");
        } else {
            System.out.println("执行老");
        }
        // ""  ""   t      f
        // ""  null   f      f
        // null  ""     o
        // null  null     o

        // ArrayList<Object> list = new ArrayList<>();
        // if ("1".equals("参数")) {
        //     list = "执行新";
        // } else {
        //     list = "执行老sql"
        // }
        // return list;
    }

    @Test
    public void t2() {
        // 使用数组
        String[] words = {"Hello", "World", "!"};
        String joinedStr1 = StringUtils.join(words, " ");
        System.out.println(joinedStr1);

        // 使用集合
        List<String> numbers = new ArrayList<>();
        numbers.add("1");
        numbers.add("2");
        numbers.add("3");
        String joinedStr2 = StringUtils.join(numbers, ",");
        System.out.println(joinedStr2);
    }

    @Test
    public void t3() {
        // 使用数组
        String[] words = {"Java", "is", "fun"};
        String joinedStr1 = String.join(" ", words);
        System.out.println(joinedStr1);

        // 使用集合
        List<String> colors = new ArrayList<>();
        colors.add("Red");
        colors.add("Green");
        colors.add("Blue");
        String joinedStr2 = String.join(",", colors);
        System.out.println(joinedStr2);
    }


}
